home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1999 Spring / macformat-077.iso / Shareware Plus / Development / Akua Sweets 131 / Akua Sweets Examples / File / LowerCase Names < prev    next >
Encoding:
Text File  |  1999-03-04  |  3.0 KB  |  144 lines  |  [TEXT/ToyS]

  1. -- Properties
  2. property kasPrefName : "LowerCaser"
  3.  
  4. -- Globals
  5. global gasInfoWind -- Info window
  6. global gasInfoPos -- Position of info window
  7. global gasFoldersToDo -- The folders left to process
  8. global gasConverted -- Number gone!
  9. global gasChecked -- Number checked!
  10. global gasPrefix -- Adjusted kasPrefix (munge the % parms)
  11.  
  12.  
  13. on open fsObjs
  14.     -- Load prefs, show window
  15.     pfLoad()
  16.     
  17.     set gasConverted to 0
  18.     set gasChecked to 0
  19.     
  20.     set gasInfoWind to display info titled kasPrefName ¬
  21.         located at gasInfoPos ¬
  22.         message "Scanning…"
  23.     
  24.     -- Do files
  25.     set gasFoldersToDo to {}
  26.     
  27.     repeat with fsObj in fsObjs
  28.         set myInfo to (basic info for fsObj)
  29.         
  30.         if (system type of myInfo is "fold") then
  31.             set gasFoldersToDo to gasFoldersToDo & {fsObj}
  32.         else
  33.             DoOne(fsObj)
  34.         end if
  35.     end repeat
  36.     
  37.     -- Do folders
  38.     repeat while gasFoldersToDo is not {}
  39.         -- Pop one off the end
  40.         set n to the number of items of gasFoldersToDo
  41.         set fsObj to item n of gasFoldersToDo
  42.         
  43.         if (n > 1) then
  44.             set gasFoldersToDo to items 1 through (n - 1) of gasFoldersToDo
  45.         else
  46.             set gasFoldersToDo to {}
  47.         end if
  48.         
  49.         display info gasInfoWind ¬
  50.             message ("Folders to go: " & n) ¬
  51.             at line 6 ¬
  52.             using color (15 * 32)
  53.         
  54.         -- Process it
  55.         GoDeep(fsObj)
  56.     end repeat
  57.     
  58.     display info gasInfoWind message "DONE!"
  59.     
  60.     pause for 5 with seconds timing -- Let screen wait...
  61.     
  62.     set gasInfoPos to screen location of ¬
  63.         (display info gasInfoWind with disposal)
  64.     
  65.     pfSave() -- Save window location
  66. end open
  67.  
  68.  
  69. on DoOne(fsObj)
  70.     set fname to catalog name of (basic info for fsObj)
  71.     
  72.     set gasChecked to gasChecked + 1
  73.     display info gasInfoWind ¬
  74.         message ("Checked: " & gasChecked) ¬
  75.         at line 4
  76.     
  77.     -- Rename to lowercase?
  78.     set flow to transcribe fname with case change to lower
  79.     considering case
  80.         if flow is not fname then
  81.             collate fsObj renaming it to flow
  82.             set gasConverted to gasConverted + 1
  83.             display info gasInfoWind ¬
  84.                 message ("Changed: " & gasConverted) ¬
  85.                 at line 5
  86.         end if
  87.     end considering
  88. end DoOne
  89.  
  90.  
  91. on GoDeep(foldObj)
  92.     display info gasInfoWind ¬
  93.         message "Path: " & (foldObj as string)
  94.     
  95.     set daddy to foldObj as string
  96.     
  97.     -- Do kinds that match
  98.     display info gasInfoWind ¬
  99.         message "Scanning files" at line 5
  100.     
  101.     if (kasExtToDo is "") then
  102.         set myItems to the entries in foldObj ¬
  103.             whose types are in kasTypesToDo
  104.     else
  105.         set myItems to the entries in foldObj ¬
  106.             whose types are in kasTypesToDo ¬
  107.             whose names match kasExtToDo
  108.     end if
  109.     
  110.     repeat with myItem in myItems
  111.         DoOne((daddy & myItem) as alias)
  112.     end repeat
  113.     
  114.     -- Do folders
  115.     display info gasInfoWind ¬
  116.         message "Scanning subfolders" at line 5
  117.     
  118.     set myItems to the entries in foldObj ¬
  119.         whose kinds are a folder
  120.     
  121.     repeat with myItem in myItems
  122.         set gasFoldersToDo to gasFoldersToDo & {(daddy & myItem) as alias}
  123.     end repeat
  124.     
  125.     -- Done
  126.     display info gasInfoWind ¬
  127.         message "…" at line 5
  128. end GoDeep
  129.  
  130.  
  131. on pfLoad()
  132.     try
  133.         set ourPrefs to (load preference named kasPrefName)
  134.         set gasInfoPos to item 1 of ourPrefs
  135.     on error
  136.         set gasInfoPos to {0, 0}
  137.     end try
  138. end pfLoad
  139.  
  140.  
  141. on pfSave()
  142.     save preference {gasInfoPos} named kasPrefName
  143. end pfSave
  144.